<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>阿泽的笔记 | 阿泽的笔记</title>
    <meta name="description" content="做一个努力的码农">
    <link rel="preload stylesheet" href="/assets/style.47519a3e.css" as="style">
    
    <script type="module" src="/assets/app.130cc073.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.cc795e4d.js">
    <link rel="modulepreload" href="/assets/chunks/theme.3ebce9b1.js">
    <link rel="modulepreload" href="/assets/tools_mysql命令.md.373a1b6c.lean.js">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5a346dfe><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5a346dfe data-v-ae24b3ad><div class="VPNavBar has-sidebar" data-v-ae24b3ad data-v-a0fd61f4><div class="container" data-v-a0fd61f4><div class="title" data-v-a0fd61f4><div class="VPNavBarTitle has-sidebar" data-v-a0fd61f4 data-v-86d1bed8><a class="title" href="/" data-v-86d1bed8><!--[--><!--]--><!----><!--[-->阿泽的笔记<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-a0fd61f4><div class="curtain" data-v-a0fd61f4></div><div class="content-body" data-v-a0fd61f4><!--[--><!--]--><div class="VPNavBarSearch search" data-v-a0fd61f4><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-a0fd61f4 data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-7f418b0f data-v-42ef59de><!--[--><span data-v-42ef59de>首页</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/case/" tabindex="0" data-v-7f418b0f data-v-42ef59de><!--[--><span data-v-42ef59de>案例</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tools/" tabindex="0" data-v-7f418b0f data-v-42ef59de><!--[--><span data-v-42ef59de>工具</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-a0fd61f4 data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-e6aabb21 data-v-ce54a7d1 data-v-b1685198><span class="check" data-v-b1685198><span class="icon" data-v-b1685198><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-ce54a7d1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-ce54a7d1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><!----><div class="VPFlyout VPNavBarExtra extra" data-v-a0fd61f4 data-v-40855f84 data-v-9c007e85><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-9c007e85><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-9c007e85><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-9c007e85><div class="VPMenu" data-v-9c007e85 data-v-e7ea1737><!----><!--[--><!--[--><!----><div class="group" data-v-40855f84><div class="item appearance" data-v-40855f84><p class="label" data-v-40855f84>Appearance</p><div class="appearance-action" data-v-40855f84><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-40855f84 data-v-ce54a7d1 data-v-b1685198><span class="check" data-v-b1685198><span class="icon" data-v-b1685198><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-ce54a7d1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-ce54a7d1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><!----><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-a0fd61f4 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-5a346dfe data-v-79c8c1df><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-79c8c1df><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-79c8c1df><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-79c8c1df>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-79c8c1df data-v-1c15a60a><button data-v-1c15a60a>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-5a346dfe data-v-b00e2fdd><div class="curtain" data-v-b00e2fdd></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-b00e2fdd><span class="visually-hidden" id="sidebar-aria-label" data-v-b00e2fdd> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-b00e2fdd><section class="VPSidebarItem level-0 collapsible has-active" data-v-b00e2fdd data-v-e31bd47b><div class="item" role="button" tabindex="0" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><h2 class="text" data-v-e31bd47b>工具</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-e31bd47b><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-e31bd47b><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-e31bd47b><!--[--><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/adb%E5%91%BD%E4%BB%A4.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>adb命令</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/arduino%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>arduino基础操作</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/cmd%20npm%20yarn%20pnpm%E5%91%BD%E4%BB%A4.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>cmd npm yarn pnpm命令</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/elementUi%E7%AC%94%E8%AE%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>elementUi笔记</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/Emmet%20Web%E5%BF%AB%E9%80%9F%E6%9E%84%E5%BB%BA%E5%91%BD%E4%BB%A4.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>Emmet Web快速构建命令</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/git%E7%AC%94%E8%AE%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>git笔记</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/js%E7%9F%A5%E8%AF%86%E7%82%B9.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>js知识点</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/linux%E5%91%BD%E4%BB%A4.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>linux命令</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/linux%E5%9F%9F%E5%90%8D%E9%85%8D%E7%BD%AE%E5%8F%8A%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>linux域名配置及反向代理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/mac%E4%BD%BF%E7%94%A8%E7%AC%94%E8%AE%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>mac使用笔记</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/mysql%E5%91%BD%E4%BB%A4.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>mysql命令</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/php%E5%9F%BA%E7%A1%80%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>php基础及常用函数</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/react.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>react</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/uniapp%E7%AC%94%E8%AE%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>uniapp笔记</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/vue%E7%AC%94%E8%AE%B0.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>vue笔记</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/tools/%E5%89%8D%E7%AB%AF%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>前端基础知识</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-b00e2fdd><section class="VPSidebarItem level-0 collapsible collapsed" data-v-b00e2fdd data-v-e31bd47b><div class="item" role="button" tabindex="0" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><h2 class="text" data-v-e31bd47b>案例</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-e31bd47b><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-e31bd47b><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-e31bd47b><!--[--><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/css%E6%8A%80%E5%B7%A7.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>css技巧</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/python%E8%87%AA%E5%8A%A8%E6%B5%8B%E8%AF%95%E8%84%9A%E6%9C%AC.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>python自动测试脚本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/uniapp%E8%B8%A9%E5%9D%91%E8%AE%B0%E5%BD%95.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>uniapp踩坑记录</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/vuex%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>vuex使用示例</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/vue%E5%85%AD%E7%A7%8Dl%E4%BC%A0%E8%BE%93%E6%96%B9%E5%BC%8F.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>vue六种l传输方式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/vue%E5%AE%9E%E4%BE%8B%E6%8A%80%E5%B7%A7.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>vue实例技巧</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E4%BC%98%E7%A7%80%E7%9A%84%E5%BC%80%E6%BA%90vue%E7%BB%84%E4%BB%B6.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>优秀的开源vue组件</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E5%89%8D%E7%AB%AF%E6%97%A5%E5%BF%97.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>前端日志</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E5%BC%80%E5%8F%91%E5%AF%8C%E6%96%87%E6%9C%AC%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>开发富文本本编辑器</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8%E9%85%8D%E7%BD%AE.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>插件使用配置</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E6%A0%B7%E5%BC%8F%E5%B8%83%E5%B1%80.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>样式布局</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-e31bd47b data-v-e31bd47b><div class="item" data-v-e31bd47b><div class="indicator" data-v-e31bd47b></div><a class="VPLink link link" href="/case/%E8%BD%ACpdf%E7%9B%B8%E5%85%B3.html" data-v-e31bd47b><!--[--><p class="text" data-v-e31bd47b>转pdf相关</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5a346dfe data-v-669faec9><div class="VPDoc has-sidebar has-aside" data-v-669faec9 data-v-6b87e69f><!--[--><!--]--><div class="container" data-v-6b87e69f><div class="aside" data-v-6b87e69f><div class="aside-curtain" data-v-6b87e69f></div><div class="aside-container" data-v-6b87e69f><div class="aside-content" data-v-6b87e69f><div class="VPDocAside" data-v-6b87e69f data-v-3f215769><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-3f215769 data-v-d330b1bb><div class="content" data-v-d330b1bb><div class="outline-marker" data-v-d330b1bb></div><div class="outline-title" role="heading" aria-level="2" data-v-d330b1bb>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-d330b1bb><span class="visually-hidden" id="doc-outline-aria-label" data-v-d330b1bb> Table of Contents for current page </span><ul class="root" data-v-d330b1bb data-v-d0ee3533><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-6b87e69f><div class="content-container" data-v-6b87e69f><!--[--><!--]--><!----><main class="main" data-v-6b87e69f><div style="position:relative;" class="vp-doc _tools_mysql%E5%91%BD%E4%BB%A4" data-v-6b87e69f><div><h2 id="基础操作" tabindex="-1">基础操作 <a class="header-anchor" href="#基础操作" aria-label="Permalink to &quot;基础操作&quot;">​</a></h2><h3 id="_1-登陆mysql" tabindex="-1">1. 登陆mysql <a class="header-anchor" href="#_1-登陆mysql" aria-label="Permalink to &quot;1. 登陆mysql&quot;">​</a></h3><p>键入命令mysql -uroot -p，</p><h3 id="_2-显示数据库列表。" tabindex="-1">2. 显示数据库列表。 <a class="header-anchor" href="#_2-显示数据库列表。" aria-label="Permalink to &quot;2.  显示数据库列表。&quot;">​</a></h3><p>show databases; 缺省有两个数据库：mysql和test。 mysql库存放着mysql的系统和用户权限信息，我们改密码和新增用户，实际上就是对这个库进行操作。</p><h4 id="_2-1-导入外部数据" tabindex="-1">2.1 导入外部数据 <a class="header-anchor" href="#_2-1-导入外部数据" aria-label="Permalink to &quot;2.1  导入外部数据&quot;">​</a></h4><p>source star.sql （进入后） mysql -uroot -p stars &lt; C:\Users\Administrator\Desktop\stars.sql (用cmd到mysql下）)</p><h4 id="_2-2-导出数据表-cmd-不进入mysql" tabindex="-1">2.2 导出数据表(cmd 不进入mysql) <a class="header-anchor" href="#_2-2-导出数据表-cmd-不进入mysql" aria-label="Permalink to &quot;2.2 导出数据表(cmd 不进入mysql)&quot;">​</a></h4><p>mysqldump -u root -p db_name &gt; test_db.sql</p><h4 id="_2-3-显示库中的数据表" tabindex="-1">2.3 显示库中的数据表： <a class="header-anchor" href="#_2-3-显示库中的数据表" aria-label="Permalink to &quot;2.3 显示库中的数据表：&quot;">​</a></h4><pre><code>	use mysql; 
	show tables;  //显示所有表
</code></pre><h3 id="_3-显示数据表的结构" tabindex="-1">3. 显示数据表的结构： <a class="header-anchor" href="#_3-显示数据表的结构" aria-label="Permalink to &quot;3.  显示数据表的结构：&quot;">​</a></h3><pre><code>    describe 表名; #或使用简写desc
show index from tables; //显示索引
显示所有表名称和注释（适用于导出表）
select table_name,table_comment from information_schema.tables 
where    
table_schema =&#39;opencenter&#39; 

导出所有字段与表结构（适用于导出）
SELECT  
	TABLE_NAME  表名,
  COLUMN_NAME 列名,  
  COLUMN_TYPE 数据类型,  
	DATA_TYPE 字段类型,  
  CHARACTER_MAXIMUM_LENGTH 长度,  
  IS_NULLABLE 是否为空,  
  COLUMN_DEFAULT 默认值,  
  COLUMN_COMMENT 备注   
FROM  
 INFORMATION_SCHEMA.COLUMNS  
where    
table_schema =&#39;opencenter&#39; 
</code></pre><h3 id="_4-建库与删库" tabindex="-1">4. 建库与删库： <a class="header-anchor" href="#_4-建库与删库" aria-label="Permalink to &quot;4.  建库与删库：&quot;">​</a></h3><pre><code>create database 库名;
drop database 库名;
</code></pre><h3 id="_5-建表" tabindex="-1">5. 建表： <a class="header-anchor" href="#_5-建表" aria-label="Permalink to &quot;5.  建表：&quot;">​</a></h3><pre><code>use 库名;
create table 表名(字段列表);
drop table 表名;
</code></pre><h3 id="_6-清空表中记录" tabindex="-1">6. 清空表中记录： <a class="header-anchor" href="#_6-清空表中记录" aria-label="Permalink to &quot;6. 清空表中记录：&quot;">​</a></h3><pre><code>delete from 表名;
</code></pre><h3 id="_7-结构增删查" tabindex="-1">7. 结构增删查 <a class="header-anchor" href="#_7-结构增删查" aria-label="Permalink to &quot;7. 结构增删查&quot;">​</a></h3><pre><code>create database name; 创建数据库
use databasename; 选择数据库
drop database name 直接删除数据库，不提醒
show tables; 显示表
describe tablename; 表的详细描述

创建表 
	create table s_position
	(
		id int not null auto_increment,
		name varchar(20) not null default &#39;经理&#39;, #设定默认值
		description varchar(100),
		primary key PK_positon (id) #设定主键
	);
删除表
	drop table staffer;
表列处理 
	添加
		ALTER TABLE `news` ADD `ceshi2` VARCHAR(33) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT &#39;//测试2&#39; AFTER `ceshi`;
	修改
		ALTER TABLE `news` CHANGE `ceshi` `ceshi` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT&#39;//测试数据要&#39; 
</code></pre><h2 id="用户管理" tabindex="-1">用户管理 <a class="header-anchor" href="#用户管理" aria-label="Permalink to &quot;用户管理&quot;">​</a></h2><h3 id="_1-查看现有用户" tabindex="-1">1. 查看现有用户 <a class="header-anchor" href="#_1-查看现有用户" aria-label="Permalink to &quot;1. 查看现有用户&quot;">​</a></h3><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">mysql&gt; select host,user,authentication_string from mysql.user;</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">mysql&gt; select host,user,authentication_string from mysql.user;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="_2-新建用户" tabindex="-1">2. 新建用户 <a class="header-anchor" href="#_2-新建用户" aria-label="Permalink to &quot;2. 新建用户&quot;">​</a></h3><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">CREATE USER &#39;username&#39;@&#39;host&#39; IDENTIFIED BY &#39;password&#39;;</span></span>
<span class="line"><span style="color:#e1e4e8;">1.mysql-&gt;create user &#39;test&#39;@&#39;localhost&#39; identified by &#39;123&#39;;</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">2.mysql-&gt;create user &#39;test&#39;@&#39;192.168.7.22&#39; identified by &#39;123&#39;;</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">3.mysql-&gt;create user &#39;test&#39;@&#39;%&#39; identified by &#39;123&#39;;</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">CREATE USER &#39;username&#39;@&#39;host&#39; IDENTIFIED BY &#39;password&#39;;</span></span>
<span class="line"><span style="color:#24292e;">1.mysql-&gt;create user &#39;test&#39;@&#39;localhost&#39; identified by &#39;123&#39;;</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">2.mysql-&gt;create user &#39;test&#39;@&#39;192.168.7.22&#39; identified by &#39;123&#39;;</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">3.mysql-&gt;create user &#39;test&#39;@&#39;%&#39; identified by &#39;123&#39;;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="_4-删除用户" tabindex="-1">4. 删除用户 <a class="header-anchor" href="#_4-删除用户" aria-label="Permalink to &quot;4. 删除用户&quot;">​</a></h3><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">mysql-&gt; drop user &#39;username&#39;@&#39;host&#39;</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">mysql-&gt; drop user &#39;username&#39;@&#39;host&#39;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="_5-授权用户" tabindex="-1">5. 授权用户 <a class="header-anchor" href="#_5-授权用户" aria-label="Permalink to &quot;5. 授权用户&quot;">​</a></h3><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">mysql&gt; GRANT privileges ON  databasename.tablename  TO  &#39;username&#39;@&#39;host&#39;</span></span>
<span class="line"><span style="color:#e1e4e8;">//示例</span></span>
<span class="line"><span style="color:#e1e4e8;">mysql&gt; GRANT ALL ON  yuyue_xihua.*  TO  &#39;yuyue_xihua&#39;@&#39;localhost&#39;;</span></span>
<span class="line"><span style="color:#e1e4e8;">mysql&gt;flush privileges;</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">mysql&gt; GRANT privileges ON  databasename.tablename  TO  &#39;username&#39;@&#39;host&#39;</span></span>
<span class="line"><span style="color:#24292e;">//示例</span></span>
<span class="line"><span style="color:#24292e;">mysql&gt; GRANT ALL ON  yuyue_xihua.*  TO  &#39;yuyue_xihua&#39;@&#39;localhost&#39;;</span></span>
<span class="line"><span style="color:#24292e;">mysql&gt;flush privileges;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><blockquote><p>privileges：表示要授予什么权力，例如可以有 select ， insert ，delete，update等，如果要授予全部权力，则填 ALL</p></blockquote><blockquote><p>databasename.tablename：表示用户的权限能用在哪个库的哪个表中，如果想要用户的权限很作用于所有的数据库所有的表，则填 *.*，*是一个通配符，表示全部。</p></blockquote><blockquote><p>’username‘@‘host’：表示授权给哪个用户。</p></blockquote><h2 id="高阶命令" tabindex="-1"><a id="advance">高阶命令</a> <a class="header-anchor" href="#高阶命令" aria-label="Permalink to &quot;&lt;a id=&quot;advance&quot;&gt;高阶命令&lt;/a&gt;&quot;">​</a></h2><h3 id="_1-查看隔离级别" tabindex="-1">1. 查看隔离级别 <a class="header-anchor" href="#_1-查看隔离级别" aria-label="Permalink to &quot;1. 查看隔离级别&quot;">​</a></h3><pre><code>  SELECT @@tx_isolation;
Faq:
READ-UNCOMMITTED(读取未提交)：** 最低的隔离级别，允许读取尚未提交的数据变更，**可能会导致脏读、幻读或不可重复读**。
READ-COMMITTED(读取已提交)：** 允许读取并发事务已经提交的数据，**可以阻止脏读，但是幻读或不可重复读仍有可能发生**。
REPEATABLE-READ(可重复读)：** 对同一字段的多次读取结果都是一致的，除非数据是被本身事务自己所修改，**可以阻止脏读和不可重复读，但幻读仍有可能发生**。
SERIALIZABLE(可串行化)：** 最高的隔离级别，完全服从ACID的隔离级别。所有的事务依次逐个执行，这样事务之间就完全不可能产生干扰，也就是说，**该级别可以防止脏读、不可重复读以及幻读**。
</code></pre><h3 id="_2-添加索引" tabindex="-1">2. 添加索引 <a class="header-anchor" href="#_2-添加索引" aria-label="Permalink to &quot;2. 添加索引&quot;">​</a></h3><h4 id="_2-1-主键索引" tabindex="-1">2.1 主键索引 <a class="header-anchor" href="#_2-1-主键索引" aria-label="Permalink to &quot;2.1 主键索引&quot;">​</a></h4><pre><code>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 
</code></pre><h4 id="_2-2-唯一索引" tabindex="-1">2.2 唯一索引 <a class="header-anchor" href="#_2-2-唯一索引" aria-label="Permalink to &quot;2.2 唯一索引&quot;">​</a></h4><pre><code>ALTER TABLE `table_name` ADD UNIQUE ( `column` ) 
</code></pre><h4 id="_2-3-普通索引" tabindex="-1">2.3 普通索引 <a class="header-anchor" href="#_2-3-普通索引" aria-label="Permalink to &quot;2.3 普通索引&quot;">​</a></h4><pre><code>ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
</code></pre><h4 id="_2-4-全文索引" tabindex="-1">2.4 全文索引 <a class="header-anchor" href="#_2-4-全文索引" aria-label="Permalink to &quot;2.4 全文索引&quot;">​</a></h4><pre><code>ALTER TABLE `table_name` ADD FULLTEXT ( `column`) 
</code></pre><h4 id="_2-5-多列索引" tabindex="-1">2.5 多列索引 <a class="header-anchor" href="#_2-5-多列索引" aria-label="Permalink to &quot;2.5 多列索引&quot;">​</a></h4><pre><code>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
</code></pre><h3 id="_3-存储引擎" tabindex="-1">3. 存储引擎 <a class="header-anchor" href="#_3-存储引擎" aria-label="Permalink to &quot;3. 存储引擎&quot;">​</a></h3><h4 id="_3-1-查看默认存储引擎" tabindex="-1">3.1 查看默认存储引擎 <a class="header-anchor" href="#_3-1-查看默认存储引擎" aria-label="Permalink to &quot;3.1 查看默认存储引擎&quot;">​</a></h4><pre><code>mysql&gt; show variables like &#39;%storage_engine%&#39;; 
</code></pre><h4 id="_3-2-查看表存储引擎" tabindex="-1">3.2 查看表存储引擎 <a class="header-anchor" href="#_3-2-查看表存储引擎" aria-label="Permalink to &quot;3.2 查看表存储引擎&quot;">​</a></h4><pre><code>show table status like &quot;table_name&quot; ;
</code></pre><h2 id="数据库备份脚本" tabindex="-1"><a id="backup">数据库备份脚本</a> <a class="header-anchor" href="#数据库备份脚本" aria-label="Permalink to &quot;&lt;a id=&quot;backup&quot;&gt;数据库备份脚本&lt;/a&gt;&quot;">​</a></h2><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;">#!/bin/bash</span></span>
<span class="line"><span style="color:#e1e4e8;">db_install_dir=/usr</span></span>
<span class="line"><span style="color:#e1e4e8;">dbrootpwd=password</span></span>
<span class="line"><span style="color:#e1e4e8;">backup_dir=/data/backupdata</span></span>
<span class="line"><span style="color:#e1e4e8;">DBname=dbname</span></span>
<span class="line"><span style="color:#e1e4e8;">expired_days=5</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">LogFile=${backup_dir}/db.log</span></span>
<span class="line"><span style="color:#e1e4e8;">DumpFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H).sql</span></span>
<span class="line"><span style="color:#e1e4e8;">NewFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H).tgz</span></span>
<span class="line"><span style="color:#e1e4e8;">OldFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d --date=&quot;${expired_days} days ago&quot;)*.tgz</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">[ ! -e &quot;${backup_dir}&quot; ] &amp;&amp; mkdir -p ${backup_dir}</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">DB_tmp=`${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e &quot;show databases\G&quot; | grep ${DBname}`</span></span>
<span class="line"><span style="color:#e1e4e8;">[ -z &quot;${DB_tmp}&quot; ] &amp;&amp; { echo &quot;[${DBname}] not exist&quot; &gt;&gt; ${LogFile} ;  exit 1 ; }</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">if [ -n &quot;`ls ${OldFile} 2&gt;/dev/null`&quot; ]; then</span></span>
<span class="line"><span style="color:#e1e4e8;">  rm -f ${OldFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">  echo &quot;[${OldFile}] Delete Old File Success&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">else</span></span>
<span class="line"><span style="color:#e1e4e8;">  echo &quot;[${OldFile}] Delete Old Backup File&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">fi</span></span>
<span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">if [ -e &quot;${NewFile}&quot; ]; then</span></span>
<span class="line"><span style="color:#e1e4e8;">  echo &quot;[${NewFile}] The Backup File is exists, Can&#39;t Backup&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">else</span></span>
<span class="line"><span style="color:#e1e4e8;">  ${db_install_dir}/bin/mysqldump -uroot -p${dbrootpwd} --databases ${DBname} &gt; ${DumpFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">  pushd ${backup_dir} &gt; /dev/null</span></span>
<span class="line"><span style="color:#e1e4e8;">  tar czf ${NewFile} ${DumpFile##*/} &gt;&gt; ${LogFile} 2&gt;&amp;1</span></span>
<span class="line"><span style="color:#e1e4e8;">  echo &quot;[${NewFile}] Backup success &quot;&gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">  rm -f ${DumpFile}</span></span>
<span class="line"><span style="color:#e1e4e8;">  popd &gt; /dev/null</span></span>
<span class="line"><span style="color:#e1e4e8;">fi</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;">#!/bin/bash</span></span>
<span class="line"><span style="color:#24292e;">db_install_dir=/usr</span></span>
<span class="line"><span style="color:#24292e;">dbrootpwd=password</span></span>
<span class="line"><span style="color:#24292e;">backup_dir=/data/backupdata</span></span>
<span class="line"><span style="color:#24292e;">DBname=dbname</span></span>
<span class="line"><span style="color:#24292e;">expired_days=5</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">LogFile=${backup_dir}/db.log</span></span>
<span class="line"><span style="color:#24292e;">DumpFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H).sql</span></span>
<span class="line"><span style="color:#24292e;">NewFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d_%H).tgz</span></span>
<span class="line"><span style="color:#24292e;">OldFile=${backup_dir}/DB_${DBname}_$(date +%Y%m%d --date=&quot;${expired_days} days ago&quot;)*.tgz</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">[ ! -e &quot;${backup_dir}&quot; ] &amp;&amp; mkdir -p ${backup_dir}</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">DB_tmp=`${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e &quot;show databases\G&quot; | grep ${DBname}`</span></span>
<span class="line"><span style="color:#24292e;">[ -z &quot;${DB_tmp}&quot; ] &amp;&amp; { echo &quot;[${DBname}] not exist&quot; &gt;&gt; ${LogFile} ;  exit 1 ; }</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">if [ -n &quot;`ls ${OldFile} 2&gt;/dev/null`&quot; ]; then</span></span>
<span class="line"><span style="color:#24292e;">  rm -f ${OldFile}</span></span>
<span class="line"><span style="color:#24292e;">  echo &quot;[${OldFile}] Delete Old File Success&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#24292e;">else</span></span>
<span class="line"><span style="color:#24292e;">  echo &quot;[${OldFile}] Delete Old Backup File&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#24292e;">fi</span></span>
<span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">if [ -e &quot;${NewFile}&quot; ]; then</span></span>
<span class="line"><span style="color:#24292e;">  echo &quot;[${NewFile}] The Backup File is exists, Can&#39;t Backup&quot; &gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#24292e;">else</span></span>
<span class="line"><span style="color:#24292e;">  ${db_install_dir}/bin/mysqldump -uroot -p${dbrootpwd} --databases ${DBname} &gt; ${DumpFile}</span></span>
<span class="line"><span style="color:#24292e;">  pushd ${backup_dir} &gt; /dev/null</span></span>
<span class="line"><span style="color:#24292e;">  tar czf ${NewFile} ${DumpFile##*/} &gt;&gt; ${LogFile} 2&gt;&amp;1</span></span>
<span class="line"><span style="color:#24292e;">  echo &quot;[${NewFile}] Backup success &quot;&gt;&gt; ${LogFile}</span></span>
<span class="line"><span style="color:#24292e;">  rm -f ${DumpFile}</span></span>
<span class="line"><span style="color:#24292e;">  popd &gt; /dev/null</span></span>
<span class="line"><span style="color:#24292e;">fi</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br></div></div><h2 id="常见问题" tabindex="-1"><a id="problem"><strong>常见问题</strong></a> <a class="header-anchor" href="#常见问题" aria-label="Permalink to &quot;&lt;a id=&quot;problem&quot;&gt;**常见问题**&lt;/a&gt;&quot;">​</a></h2><h3 id="_1-连接类问题" tabindex="-1">1. 连接类问题 <a class="header-anchor" href="#_1-连接类问题" aria-label="Permalink to &quot;1. 连接类问题&quot;">​</a></h3><pre><code>开通用局域网ip连接数据库(给用户权限同此方法)
	1.grant all privileges on *.* to &#39;用户名&#39;@&#39;IP地址&#39; identified by &#39;密码&#39;; #进入数据库给权限
	2. flush privileges;     #刷新权限表
	3.重启数据库
</code></pre><h3 id="_2-忘记密码" tabindex="-1">2. 忘记密码 <a class="header-anchor" href="#_2-忘记密码" aria-label="Permalink to &quot;2. 忘记密码&quot;">​</a></h3><h4 id="windows部分" tabindex="-1">windows部分 <a class="header-anchor" href="#windows部分" aria-label="Permalink to &quot;windows部分&quot;">​</a></h4><pre><code>方法1;
</code></pre><p>2.1 关闭mysql服务 2.2 在CMD命令行窗口，进入MYSQL安装目录 比如E:\Program Files\MySQL\MySQL Server 5.0\bin 2.3 进入mysql安全模式，即当mysql起来后，不用输入密码就能进入数据库。 命令为： mysqld-nt --skip-grant-tables 2.4 重新打开一个CMD命令行窗口，输入mysql -uroot -p，使用空密码的方式登录MySQL（不用输入密码，直接按回车） 2.5 输入以下命令开始修改root用户的密码（注意：命令中mysql.user中间有个“点”） mysql&gt; update mysql.user set password=PASSWORD(&#39;新密码&#39;) where User=&#39;root&#39;; <a href="/5.xn--7-no6a30a.html">//5.7以下</a> update mysql.user set authentication_string=password(&#39;123qwe&#39;) where user=&#39;root&#39; and Host = &#39;localhost&#39;; <a href="/5.xn--7-856b314a.html">//5.7版本</a> 2.6 刷新权限表 mysql&gt; flush privileges; 2.7 退出 mysql&gt; quit 方法2： 2.1 my.ini里面找到mysqld配置项 [mysqld] port=3306 下面添加 skip-grant-tables 之后可跳过密码输入 进入命令端 2.2 之后更改密码 输入：update mysql.user set password=password(&quot;新密码&quot;) where user=root; 2.3 改完密码后，删除my.ini里面添加的 skip-grant-tables 就可以了</p><h4 id="linux-部分" tabindex="-1">(linux 部分) <a class="header-anchor" href="#linux-部分" aria-label="Permalink to &quot;(linux 部分)&quot;">​</a></h4><p>3.1 编辑 MySQL 配置文件 my.cnf vim /etc/my.cnf [mysqld] skip-grant-tables //增加 3.2 重启 MySQL 服务 /etc/init.d/mysqld restart 或 service mysqld restart 3.3 登录mysql 修改</p><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#e1e4e8;"></span></span>
<span class="line"><span style="color:#e1e4e8;">			mysql -p</span></span>
<span class="line"><span style="color:#e1e4e8;">			mysql&gt; USE mysql;</span></span>
<span class="line"><span style="color:#e1e4e8;">            mysql&gt; update mysql.user set authentication_string=password(&#39;123qwe&#39;) where user=&#39;root&#39; ;   //5.7版本</span></span>
<span class="line"><span style="color:#e1e4e8;">            mysql&gt; flush privileges ;</span></span>
<span class="line"><span style="color:#e1e4e8;">			mysql&gt; quit</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#24292e;"></span></span>
<span class="line"><span style="color:#24292e;">			mysql -p</span></span>
<span class="line"><span style="color:#24292e;">			mysql&gt; USE mysql;</span></span>
<span class="line"><span style="color:#24292e;">            mysql&gt; update mysql.user set authentication_string=password(&#39;123qwe&#39;) where user=&#39;root&#39; ;   //5.7版本</span></span>
<span class="line"><span style="color:#24292e;">            mysql&gt; flush privileges ;</span></span>
<span class="line"><span style="color:#24292e;">			mysql&gt; quit</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>3.4 删除或者注释第一步骤中添加的 spik-grant-tables 3.5 重启 MySQL 服务 /etc/init.d/mysqld restart</p><ol start="3"><li>误删mysql root用户 3.1 vim /etc/my.cnf #编辑 MySQL 配置文件 my.cnf [mysqld] spik-grant-tables #增加 3.2 /etc/init.d/mysqld restart #重启 MySQL 服务 或使用 service mysqld restart 3.3 mysql -p #登录mysql 修改 3.4 提示，Enter password: #直接按回车 3.5 mysql&gt;use mysql #使用mysql表 3.6 mysql&gt; insert into user set user=&#39;root&#39;,ssl_cipher=&#39;&#39;,x509_issuer=&#39;&#39;,x509_subject=&#39;&#39;; #创建一个root用户 3.7 msyql&gt; update user set Host=&#39;localhost&#39;,select_priv=&#39;y&#39;,insert_priv=&#39;y&#39;,update_priv=&#39;y&#39;,Alter_priv=&#39;y&#39;,delete_priv=&#39;y&#39;,create_priv=&#39;y&#39;,drop_priv=&#39;y&#39;,reload_priv=&#39;y&#39;,shutdown_priv=&#39;y&#39;,Process_priv=&#39;y&#39;,file_priv=&#39;y&#39;,grant_priv=&#39;y&#39;,References_priv=&#39;y&#39;,index_priv=&#39;y&#39;,create_user_priv=&#39;y&#39;,show_db_priv=&#39;y&#39;,super_priv=&#39;y&#39;,create_tmp_table_priv=&#39;y&#39;,Lock_tables_priv=&#39;y&#39;,execute_priv=&#39;y&#39;,repl_slave_priv=&#39;y&#39;,repl_client_priv=&#39;y&#39;,create_view_priv=&#39;y&#39;,show_view_priv=&#39;y&#39;,create_routine_priv=&#39;y&#39;,alter_routine_priv=&#39;y&#39;,create_user_priv=&#39;y&#39; where user=&#39;root&#39;; #设置root用户的权限，所有权限为 &#39; y &#39; ，即拥有最高权限。***关键：如果报错，Host主键不能修改则去掉 (Host=&#39;localhost&#39;,)部分 3.8 mysql&gt;exit #退出mysql数据库。 3.9 service mysqld restart #重启数据库 3.10 #mysql -u root -p 按[enter]在按[enter] 因为我们前面没有帮root用户设置密码，所有现在以root用户进入修改密码 3.11 mysql&gt;update user set password=password(&#39;123456&#39;) where user=&#39;root&#39;; 修改root密码 3.12 mysql&gt;flush privileges; 刷新用户权限，这里你也可以重启mysql 3.13 mysql&gt;exit 退出mysql数据库。 3.14 删除或者注释第一步骤中添加的 spik-grant-tables 　　 至此，大功告成。a</li></ol></div></div></main><footer class="VPDocFooter" data-v-6b87e69f data-v-ef5dee53><!--[--><!--]--><!----><nav class="prev-next" data-v-ef5dee53><div class="pager" data-v-ef5dee53><a class="pager-link prev" href="/tools/mac%E4%BD%BF%E7%94%A8%E7%AC%94%E8%AE%B0.html" data-v-ef5dee53><span class="desc" data-v-ef5dee53>Previous page</span><span class="title" data-v-ef5dee53>mac使用笔记</span></a></div><div class="pager" data-v-ef5dee53><a class="pager-link next" href="/tools/php%E5%9F%BA%E7%A1%80%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0.html" data-v-ef5dee53><span class="desc" data-v-ef5dee53>Next page</span><span class="title" data-v-ef5dee53>php基础及常用函数</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"case_getaccesstoken.md\":\"67a16083\",\"case_前端日志.md\":\"270996e6\",\"case_前端防切屏.md\":\"6d67367b\",\"ai学习笔记_个人理解.md\":\"62e8b40f\",\"case_vue实例技巧.md\":\"75787181\",\"日志_关于企业站的seo.md\":\"496419f4\",\"case_插件使用配置.md\":\"fe83b1c1\",\"办公_版本处理方案.md\":\"e749eb0e\",\"办公_开发记录.md\":\"437c4662\",\"case_mac使用.md\":\"48c33f34\",\"办公_app开通微信支付.md\":\"95c825d6\",\"tools_arduino基础操作.md\":\"f997fb69\",\"日志_uniapp内存泄漏事件.md\":\"25a76630\",\"case_ios上架笔记.md\":\"84d52929\",\"case_开发富文本本编辑器.md\":\"d7842807\",\"办公_ebm后端及数据库笔记.md\":\"0c19b5f3\",\"case_uniapp踩坑记录.md\":\"4e47ad2a\",\"tools_conda命令  pip命令.md\":\"23ac8380\",\"办公_待解决问题.md\":\"dcc132f1\",\"case_优秀的开源vue组件.md\":\"6020f82e\",\"case_样式布局.md\":\"670153be\",\"tools_emmet web快速构建命令.md\":\"02ded381\",\"ai学习笔记_二、应用场景.md\":\"3985787b\",\"java笔记_程序基础.md\":\"750d7bf5\",\"日志_合格的文档.md\":\"e2dd10c4\",\"tools_index.md\":\"8efae136\",\"tools_设计规范.md\":\"c1e5222d\",\"case_转pdf相关.md\":\"9b047234\",\"case_vuex使用示例.md\":\"042f3339\",\"tools_elementui笔记.md\":\"d727814f\",\"办公_应用中心框架更新.md\":\"9124a7e9\",\"ai学习笔记_一、概念.md\":\"960b8e6d\",\"case_markdown文件转换目录列表.md\":\"f04a5805\",\"tools_cmd npm yarn pnpm命令.md\":\"deebc540\",\"case_css技巧.md\":\"cedd6cee\",\"ai学习笔记_四、模型.md\":\"f9d2ec81\",\"办公_代码示例_l律所起诉状.md\":\"f875bace\",\"tools_adb命令.md\":\"9831c553\",\"tools_命名汇总推荐.md\":\"3bf819e1\",\"办公_seo方案.md\":\"22a7e45f\",\"java笔记_面向对象编程.md\":\"486db2ad\",\"日志_测试笔记.md\":\"00dcc692\",\"case_python自动测试脚本.md\":\"bec8212a\",\"index.md\":\"25642d62\",\"tools_mac使用笔记.md\":\"9ee5b2a6\",\"办公_实施笔记.md\":\"10ecc800\",\"tools_vue笔记.md\":\"be570cd4\",\"ai学习笔记_五、模型发展.md\":\"a9feb551\",\"case_vue六种l传输方式.md\":\"cadce3ad\",\"case_index.md\":\"4370ee15\",\"ai学习笔记_六、开发.md\":\"0b1a367a\",\"tools_前端基础知识.md\":\"864e9786\",\"ai学习笔记_三、promt工程.md\":\"1b5a7f7c\",\"办公_todo.md\":\"2ccf3c97\",\"日志_前端自检项.md\":\"0544de55\",\"case_基础csss样式.md\":\"d368d629\",\"tools_react.md\":\"d032d22f\",\"case_数字化大屏问题点.md\":\"e37019d4\",\"tools_php基础及常用函数.md\":\"b2afeccf\",\"case_flutter安装配置.md\":\"ccbc694e\",\"tools_js知识点.md\":\"51436346\",\"case_富文本编辑器原理.md\":\"f3b0b2ee\",\"tools_mysql命令.md\":\"373a1b6c\",\"tools_linux命令.md\":\"82c20701\",\"办公_前端常用代码.md\":\"8923abd6\",\"tools_jquery的使用.md\":\"e9d67fbd\",\"tools_docker使用.md\":\"1ea0c513\",\"tools_uniapp笔记.md\":\"c0a178f5\",\"tools_git笔记.md\":\"9870fad6\",\"日志_自媒体笔记.md\":\"0d283ba7\",\"tools_linux域名配置及反向代理.md\":\"25492670\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"阿泽的笔记\",\"description\":\"做一个努力的码农\",\"base\":\"/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"displayAllHeaders\":true,\"nav\":[{\"text\":\"首页\",\"link\":\"/\"},{\"text\":\"案例\",\"link\":\"/case/\"},{\"text\":\"工具\",\"link\":\"/tools/\"}],\"sidebar\":[{\"text\":\"工具\",\"collapsible\":true,\"collapsed\":true,\"items\":[{\"text\":\"adb命令\",\"link\":\"/tools/adb命令\"},{\"text\":\"arduino基础操作\",\"link\":\"/tools/arduino基础操作\"},{\"text\":\"cmd npm yarn pnpm命令\",\"link\":\"/tools/cmd npm yarn pnpm命令\"},{\"text\":\"elementUi笔记\",\"link\":\"/tools/elementUi笔记\"},{\"text\":\"Emmet Web快速构建命令\",\"link\":\"/tools/Emmet%20Web快速构建命令\"},{\"text\":\"git笔记\",\"link\":\"/tools/git笔记\"},{\"text\":\"js知识点\",\"link\":\"/tools/js知识点\"},{\"text\":\"linux命令\",\"link\":\"/tools/linux命令\"},{\"text\":\"linux域名配置及反向代理\",\"link\":\"/tools/linux域名配置及反向代理\"},{\"text\":\"mac使用笔记\",\"link\":\"/tools/mac使用笔记\"},{\"text\":\"mysql命令\",\"link\":\"/tools/mysql命令\"},{\"text\":\"php基础及常用函数\",\"link\":\"/tools/php基础及常用函数\"},{\"text\":\"react\",\"link\":\"/tools/react\"},{\"text\":\"uniapp笔记\",\"link\":\"/tools/uniapp笔记\"},{\"text\":\"vue笔记\",\"link\":\"/tools/vue笔记\"},{\"text\":\"前端基础知识\",\"link\":\"/tools/前端基础知识\"}]},{\"text\":\"案例\",\"collapsible\":true,\"collapsed\":true,\"items\":[{\"text\":\"css技巧\",\"link\":\"/case/css技巧\"},{\"text\":\"python自动测试脚本\",\"link\":\"/case/python自动测试脚本\"},{\"text\":\"uniapp踩坑记录\",\"link\":\"/case/uniapp踩坑记录\"},{\"text\":\"vuex使用示例\",\"link\":\"/case/vuex使用示例\"},{\"text\":\"vue六种l传输方式\",\"link\":\"/case/vue六种l传输方式\"},{\"text\":\"vue实例技巧\",\"link\":\"/case/vue实例技巧\"},{\"text\":\"优秀的开源vue组件\",\"link\":\"/case/优秀的开源vue组件\"},{\"text\":\"前端日志\",\"link\":\"/case/前端日志\"},{\"text\":\"开发富文本本编辑器\",\"link\":\"/case/开发富文本本编辑器\"},{\"text\":\"插件使用配置\",\"link\":\"/case/插件使用配置\"},{\"text\":\"样式布局\",\"link\":\"/case/样式布局\"},{\"text\":\"转pdf相关\",\"link\":\"/case/转pdf相关\"}]}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
    
  </body>
</html>